package tgc.edu.exam.repository;

import java.util.List;
import java.util.UUID;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import tgc.edu.exam.custom.CommonRepository;
import tgc.edu.exam.entity.SysRole;

@Repository
public interface SysRoleRepository extends CommonRepository<SysRole, UUID>{

	public List<SysRole> findByParentIsNull();

	public SysRole findByCode(String code);

	public List<SysRole> findByParent(SysRole role);
	
	@Modifying
	@Query(value="update SysRole t set t.code=?2 where t.code=?1")
	public void changeCode(String oldCode, String newCode);
	
	@Modifying
	@Query(value="update SysRole t set t.name=?2 where t.name=?1")
	public void changeName(String oldName, String newName);



}
